package com.csgc.camera.widget.mask

import android.content.Context
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.csgc.camera.constants.MaskConfig
import com.cysd.spsyxj.R


class MaskZhiQin:MaskBase {

    constructor(context: Context?, id:Int) : super(context,null){
        if(id == 0){
            LayoutInflater.from(context).inflate(R.layout.item_mask_zhi_qin_1, this, true)
        }else if(id == 1){
            customTextColor = ContextCompat.getColor(context!!,R.color.color_333333)
            LayoutInflater.from(context).inflate(R.layout.item_mask_zhi_qin_2, this, true)
        }
        dateStyle = "yyyy/MM/dd"
        if(MaskConfig.maskDateStyle.isNotEmpty()){
            dateStyle = MaskConfig.maskDateStyle
        }
        initView()

    }

    private fun initView(){
        date = findViewById(R.id.tv_zhi_qin_date)
        time = findViewById(R.id.tv_zhi_qin_time)
        week = findViewById(R.id.tv_zhi_qin_week)
        location = findViewById(R.id.tv_zhi_qin_location)
        customMaskContainer = findViewById(R.id.layout_custom_mask_container)
        location?.text = MaskConfig.maskLocation
        changeDateTime()
        MaskConfig.customMaskInfo.forEach {
            val text = TextView(context)
            text.setTextColor(customTextColor)
            text.setTextSize(TypedValue.COMPLEX_UNIT_SP,12f)
            text.text = "${it.title}:${it.content}"
            text.visibility = if (it.isOpen) View.VISIBLE else View.GONE

            customMaskContainer?.addView(text)
        }




    }

}